/*
 * Exemplo de copyright
 * 
 * Copyright (c) ***Ian F. Darwin, http://www.darwinsys.com/, 1996-2002***.
 * All rights reserved. Software written by ***Ian F. Darwin*** and others.
 * ***$Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp*** $
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package wdmsim;

import java.io.IOException;
import tracing.Statistic;

/**
 * @author Alissonslp
 *
 */
public final class Main {

	/**
	 * 
	 * @param args comand-line options
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		Simulator wdm;
		//String usage = "Usage: WDMSim simulation_file seed [-trace] [tracerName] [-verbose] [minload maxload step]";
		String usage = "Usage: WDMSim simulation_file seed [-trace] [tracerName] [-verbose] load protocol";
		String simConfigFile = args[0];
		int seed = Integer.parseInt(args[1]);
		boolean trace = true;
		String traceFileName = args[3];
		boolean verbose = true;		
		int load = Integer.parseInt(args[5]);
		String protocol = args[6];
		//int minload = 0, maxload = 0, step = 1;
		
		/*if(args.length<3 || args.length>7) {
			System.out.println(usage);
			System.exit(0);
			
		} else if(args.length==5) {
			if(args[2].equals("-trace") && args[4].equals("-verbose")) {
				trace = true;
				traceFileName = args[3];
				verbose = true;
			}
			
		} else if(args.length==8) {
			trace = true;
			traceFileName = args[3];
			verbose = true;
			minload = Integer.parseInt(args[5]);
			maxload = Integer.parseInt(args[6]);
			step = Integer.parseInt(args[7]);
		}
		// parsing comand-line options
		if (args.length < 2 || args.length > 8) {
			System.out.println(usage);
			System.exit(0);
		} else {
			if (args.length == 5 || args.length == 8) {
				if (args[2].equals("-verbose")) {
					verbose = true;
				} else {
					if (args[2].equals("-trace")) {
						trace = true;
						tracerName = args[3];
					} else {
						System.out.println(usage);
						System.exit(0);
					}
				}
			}
			if (args.length == 4 || args.length == 8) {
				if ((args[2].equals("-trace") && args[4].equals("-verbose"))
						|| (args[4].equals("-trace") && args[2]
								.equals("-verbose"))) {
					trace = true;
					tracerName = args[3];
					verbose = true;
				} else {
					System.out.println(usage);
					System.exit(0);
				}
			}
			if (args.length == 6 || args.length == 7 || args.length == 8) {
				minload = Integer.parseInt(args[args.length - 3]);
				maxload = Integer.parseInt(args[args.length - 2]);
				step = Integer.parseInt(args[args.length - 1]);
			}
		}*/
		

		//for (int load = minload; load <= maxload; load += step) {
			wdm = new Simulator();
			wdm.Execute(simConfigFile, trace, traceFileName, verbose, load, seed, protocol);
		//}
	}
}
